<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<title>修改个人资料</title>
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/common.css" />
		<!-- Bootstrap Core CSS -->
		<link href="../../sbadmin/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
		<!-- MetisMenu CSS -->
		<link href="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
		<!-- DataTables CSS -->
		<link href="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
		<!-- Custom CSS -->
		<link href="../../sbadmin/dist/css/sb-admin-2.css" rel="stylesheet">
		<!-- Custom Fonts -->
		<link href="../../sbadmin/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" href="../../css/jquery.datetimepicker.css" />
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
		<style>
			body {
				padding: 0 15px !important;
			}
		</style>
	</head>

	<body style="background:#FFF;">
		<div class="comm-tt-font pr">
			会员信息 > 会员详情 > 修改会员资料
		</div>
		<div class="zl-ccbox">
			<div class="zl-cctt">
				<ul class="zl-list-ul clb">
					<li>
						<a href="personalMsg.html" class="cur">个人资料</a>
					</li>
					<li>
						<a href="babyMsg.html">宝宝资料</a>
					</li>
					<li>
						<a href="order.html">订单</a>
					</li>
				</ul>
			</div>
			<div class="zl-cccc pr">
				<div class="edit-item clb">
					<div class="edit-item-tt fl"><em>*</em>姓名：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="pmName" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl">性别：</div>
					<div class="edit-item-cc fl ml10">
						<div class="sexbox fl" id="nan">男</div>
						<div class="sexbox fl" id="nv">女</div>
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl"><em>*</em>手机号：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="pmTel" disabled="disabled" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl">身份证：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="pmIcard" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl"><em>*</em>生日：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="pmBir" style="width: 200px;" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl"><em>*</em>电子邮件：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="pmMail" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl">通讯地址：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="pmAddr" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl"></div>
					<div class="edit-item-cc fl ml10">
						<a href="personalMsg.html" class="fl commqx-btn">取消</a>
						<a href="javascript:void(0)" class="fl commqr-btn ml15" id="pmCfm">确定</a>
					</div>
				</div>
			</div>
		</div>

		<!-- jQuery -->
		<script src="../../sbadmin/bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap Core JavaScript -->
		<script src="../../sbadmin/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- Metis Menu Plugin JavaScript -->
		<script src="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.js"></script>
		<!-- DataTables JavaScript -->
		<script src="../../sbadmin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
		<script src="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
		<!-- Custom Theme JavaScript -->
		<script src="../../sbadmin/dist/js/sb-admin-2.js"></script>
		<script type="text/javascript" src="../../js/layer/layer.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script type="text/javascript" src="../../js/jquery.datetimepicker.full.js"></script>
		<!-- Page-Level Demo Scripts - Tables - Use for reference -->
	</body>
	<script>
		$(function() {
			$.datetimepicker.setLocale('ch');
			$('#pmBir').datetimepicker({
				lang: "ch", //语言选择中文 注：旧版本 新版方法：$.datetimepicker.setLocale('ch');
				format: 'Y-m-d',
				timepicker: false, //关闭时间选项
				yearStart: 2000, //设置最小年份
				yearEnd: 2050, //设置最大年份
				todayButton: false, //关闭选择今天按钮
				step: 5,
				//  startDate: enddate + "-" + "01"
			});
			var id = localStorage.getItem("id", id);
			var user = {
				"id": id
			}
			$.ajax({
				url: "https://order.wz1996.wang/wzbg/user/query/customer",
				type: 'post',
				contentType: 'application/json',
				data: JSON.stringify(user),
				beforeSend: function(request) {
					request.setRequestHeader("token", localStorage.getItem("token"));
				},
				success: function(data) {
					console.log(data);
					if(data.code == "1") {
						$("#pmName").val(data.data[0].name);
						if(data.data[0].sex == "1") {
							$("#nan").addClass("cur")
						} else if(data.data[0].sex == "0") {
							$("#nv").addClass("cur")
						}
						$("#pmTel").val(data.data[0].phone);
						$("#pmIcard").val(data.data[0].identityCard);
						$("#pmBir").val(data.data[0].birthday.split(" ")[0]);
						$("#pmMail").val(data.data[0].email);
						$("#pmAddr").val(data.data[0].address);
					} else if(data.code == "-1") {
						layar(data.msg);
						setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
					} else {
						layar(data.msg);
					}
				},
				error: function(e) {
					errcode(e);
				}
			});
			//修改
			$("#pmCfm").click(function() {
				var pmName = $("#pmName").val();
				var pmSex = "";
				if($("#nan").hasClass("cur")) {
					pmSex = "1"
				} else {
					pmSex = "0"
				}
				var pmTel = $("#pmTel").val();
				var pmIcard = $("#pmIcard").val();
				var pmBir = $("#pmBir").val() + " 00:00:00";
				var pmMail = $("#pmMail").val();
				var pmAddr = $("#pmAddr").val();
				var post_data = {
					"address": pmAddr,
					"birthday": pmBir,
					"email": pmMail,
					"id": id,
					"identityCard": pmIcard,
					"name": pmName,
					"phone": pmTel,
					"sex": pmSex
				}
				if(pmName == "") {
					layar("姓名不能为空");
				} else if(pmTel == "") {
					layar("手机号不能为空");
				} else if(pmBir == "") {
					layar("生日不能为空");
				} else if(pmMail == "") {
					layar("电子邮件不能为空");
				} else {
					$.ajax({
						url: "https://order.wz1996.wang/wzbg/user/customer/update",
						type: 'put',
						contentType: 'application/json',
						data: JSON.stringify(post_data),
						beforeSend: function(request) {
							request.setRequestHeader("token", localStorage.getItem("token"));
						},
						success: function(data) {
							console.log(data);
							if(data.code == "1") {
								layar("修改成功！");
								setTimeout("window.location.href='personalMsg.html'", 1000)
							} else if(data.code == "-1") {
								layar(data.msg);
								setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
							} else {
								layar(data.msg);
							}
						},
						error: function(e) {
							errcode(e);
						}
					});
				}
			})
			$(".sexbox").click(function() {
				$(this).addClass("cur").siblings().removeClass("cur");
			})
		})
	</script>

</html>